#include<stdio.h>
#include<conio.h>
void main()
{
	int n, i, f = 1, e;

	clrscr();
	/******* Start of Input validation ******/
	printf("\n\n\t\tEnter any no. ");

	while(1)
	{
		scanf("%d", &n);
		//if(n >= 48 && n <= 57)
		if( n > 7)
		{
			printf("\n\n\t\tInvalid number!!!.\n\n\t\tPlease enter again: ");
		}
		else
		{
			break;
		}
	}
	/******* Start of Input validation	 ******/

	/***** Start of Factorial Logic ****/
	for(i = n; i >= 1; i--)
	{
		e = f;
		f = f * i;
		printf("\n\n\t\t%d * %d = %d", i, e, f);
	}

	printf("\n\n\t\tFactorial = %d", f);
	/***** End of Factorial Logic ****/

	getch();
}